package com.ymatou.iapi.godmch.testcase;

import java.util.Map;

import org.apache.commons.collections.map.HashedMap;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.getInviteDistributorOrganizationPicBean;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.getInviteDistributorOrganizationPicCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.invite_code;
import com.ymttest.database.sqlwapper.godmch.invite_codeWapper;
/**
*获取邀请分销机构分享图片
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getInviteDistributorOrganizationPic{
	private static getInviteDistributorOrganizationPicBean bean;
	private static getInviteDistributorOrganizationPicCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取邀请分销机构分享图片");
	}

	@Before
	public void caseUp() {
		bean=new getInviteDistributorOrganizationPicBean();
		call=new getInviteDistributorOrganizationPicCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getInviteDistributorOrganizationPic_001() {
		Logger.start(true,"获取邀请分销机构分享图片");
		try {
			
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

            bean.setMchId(mchId);
			call.setData(bean);
			call.callService();			
			
			invite_codeWapper codeWapper=new invite_codeWapper();
			Map<String,Object> map=new HashedMap();
			map.put("mchId",  bean.getMchId());
			invite_code code=codeWapper.selectby(map).get(0);
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(code.getInviteCode(), call.getInviteCode(), "验证InviteCode");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");	
			Logger.verifyEquals(code.getCodeRole(),6, "验证codeRole");
			Logger.verifyEquals(code.getAgentModel(),1, "验证AgentModel");
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}